Triggers
Use triggers and actions to create interactions. Use triggers to set off actions, such as setting a property to a certain value or setting the state of an application. Messages are generated, for example, from the user input and handled by the UI components according to their specified behavior.
Most of the message handling behavior is predefined in a UI component, such as scrolling in a list box, but you can define much of behavior to meet the requirements of your application. For example, the simplest UI component, a button, creates a click message whenever a user clicks, or taps it, but you can define what happens after the generated click message. An example action is that a click triggers an animation that highlights the button the user clicked.
All Kanzi objects can send and receive messages that can be intercepted with triggers. Certain UI components can receive messages from specific user input events. For example, a button can receive click messages and a scroll view can receive scroll messages.
These concepts relate to defining event-driven logic:
- Input and hit testing. Input is first recognized in a hit testing phase, where all nodes that have hit testing enabled participate. If a pointer event (for example, mouse button down) is performed on top of components that participate in hit testing, only the top most component receives the input. If the component has a manipulator that reacts to the received type of input, it can generate messages (for example, a click message). You can set the Hit Testable property in Kanzi Studio. See Using input manipulators and Using triggers.
- Input manipulators. A manipulator reacts to a specific type of input such as panning, click, or long press. You cannot add manipulators in Kanzi Studio, but you can use UI components that contain specific types of manipulators. For example, a scroll view contains a pan manipulator and a button includes a click manipulator. See Using input manipulators.
- Messages. Messages are used to communicate between nodes in the scene graph. The messages travel between nodes using a process called tunneling and bubbling. The message achieves its target node during tunneling and then starts to travel from child to parent during bubbling until a trigger is intercepted and the message set as handled (consumed). You can thus place triggers in ancestors as well as the controls themselves. For example, you can place a trigger called radioButtonHandler to the parent of multiple buttons. See Using messages.
- Triggers. Triggers react to messages or events and apply logic. In Kanzi Studio the logic is limited to certain types of actions, such as Set Property, but in application code, it can contain anything. Additionally a trigger has various trigger settings. Trigger settings include trigger conditions, such as Set Message Handled, which prevents the message from bubbling further up to other triggers. You can add multiple triggers to a single message or event and each can have specific settings and conditions. See Using triggers.
- Actions. An action is an outcome of a trigger. There are general actions like Set Property, Write Log, Activate Theme, and actions you can use to control a specific type of item such as, Go to State, Set Scroll Target, or Navigate to Page.
See also
Using triggers
Using input manipulators
Using messages
Triggers reference
Actions reference
Open topic with navigation